package frankenstein.datastructures;

import java.util.*;
public class Period extends ParentModel {

	private ArrayList<Generation> generations;
	
	private int id;

	private String name;	

	private Weights weights;
	
	private MutationParameters mutationParameters;
	
	private ScenarioData scenarios; 
	
	private Settings settings;
	
	private int terminatingGeneration;
	
	public Period(){
		name="Period";
		generations = new ArrayList<Generation>();		
		weights = new Weights();
		mutationParameters = new MutationParameters();
		scenarios = new ScenarioData();
		settings = new Settings();
		
	}
	
	public Period(String namestr) {
		name = namestr;
		generations = new ArrayList<Generation>();
		weights = new Weights();
		mutationParameters = new MutationParameters();
		scenarios = new ScenarioData();
		settings = new Settings();
	}

	public Settings getSettings() {
		return settings;
	}

	public void setSettings(Settings settings) {
		this.settings = settings;
	}

	public ScenarioData getScenarios() {
		return scenarios;
	}

	public void setScenarios(ScenarioData scenarios) {
		this.scenarios = scenarios;
	}

	public MutationParameters getMutationParameters() {
		return mutationParameters;
	}

	public void setMutationParameters(MutationParameters mutationParameters) {
		this.mutationParameters = mutationParameters;
	}

	public Weights getWeights() {
		return weights;
	}

	public void setWeights(Weights weights) {
		this.weights = weights;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public ArrayList<Generation> getGenerations() {
		return generations;
	}

	public void setGenerations(ArrayList<Generation> generations) {
		this.generations = generations;
	}

	public void addGeneration(Generation generation){
		this.generations.add(generation);
	}
	
	public Generation getLastGeneration(){
		return generations.get(generations.size()-1);
	}
	public void setLastGeneration(Generation lastGeneration){
		generations.set(generations.size()-1, lastGeneration);
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getTerminatingGeneration() {
		return terminatingGeneration;
	}

	public void setTerminatingGeneration(int terminatingGeneration) {
		this.terminatingGeneration = terminatingGeneration;
	}

	public Period createClone() {
		Period clone = new Period();
		
		for(Generation generation: generations){			
			clone.getGenerations().add(generation.createClone());
		}
		clone.setId(id);
		//clone.setLastGeneration(getLastGeneration());	
		clone.setName(name);
		clone.setTerminatingGeneration(terminatingGeneration);
		clone.setMutationParameters(mutationParameters.createClone());
		clone.setSettings(settings.createClone());
		clone.setWeights(weights.createClone());
		clone.setScenarios(scenarios.createClone());
		
		
		return clone;
	}
	
}
